package com.example.bysj.Service;
//201902104061徐中堂
import com.example.bysj.Dao.SchoolDao;
import com.example.bysj.Dao.UserDao;
import com.example.bysj.domain.School;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
//声明一个业务处理类
@Service("schoolService")
//@Transactional注解：可以用在方法上和类上，用在类上代表这个类的所有公共非静态方法都将启用事务功能。
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation. REQUIRED)
public class SchoolService {
    @Autowired
    private SchoolDao schoolDao;
    //添加
    public Boolean add(School school){
        return schoolDao.add(school);
    }
    //根据id查找
    public School find(int id){
        School school = schoolDao.find(id);
        return school;
    }
    //查找全部
    public List<School> findAll(){
        List<School> schools = schoolDao.findAll();
        return schools;
    }
    //修改
    public Boolean update(School school){
        return schoolDao.update(school);
    }
    //删除
    public Boolean delete(int id){
        return schoolDao.delete(id);
    }
}